package com.meida.module.bus.client.entity.srmapi.psmtosrm;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;

@ApiModel("响应结果")
@Data
@ToString
public class PMSResultBody<T> implements Serializable {
    @ApiModelProperty("0：正常 1：错误 2：异常")
    private int code;
    @ApiModelProperty("提示消息")
    private String msg;
    @ApiModelProperty("提示消息")
    private T data;

    public static PMSResultBody ok(String message) {
        return (new PMSResultBody()).code(0).msg(message);
    }

    public static PMSResultBody ok(String message, Object data) {
        return (new PMSResultBody()).code(0).msg(message).data(data);
    }

    public static PMSResultBody err(String message) {
        return (new PMSResultBody()).code(1).msg(message);
    }

    public static PMSResultBody err(String message, Object data) {
        return (new PMSResultBody()).code(1).msg(message).data(data);
    }


    public PMSResultBody code(int code) {
        this.code = code;
        return this;
    }

    public PMSResultBody msg(String message) {
        this.msg = message;
        return this;
    }

    public PMSResultBody data(T data) {
        this.data = data;
        return this;
    }
}
